﻿#pragma execution_character_set("utf-8")
// 本文件为utf-8 编码格式

#include "LeftMenuViewController.h"
#include "CartoonHouse.h"
#include "FirstViewController.h"
#include "../Util/GDUtil.h"
#include "../Util/GDStatisticsUtil.h"
#include "../GdDefine.h"
#include "GdWebviewViewController.h"	

LeftMenuViewController::LeftMenuViewController()
:m_pCollectionView(NULL)
, m_pMyInfoLabel(NULL)
, m_pTableView(NULL)
, m_pHeadImgView(NULL)
, m_pHeadImgStatus(NULL)
, m_uliTmpSize(0)
, bgImage(NULL)
, m_pHeadButton(NULL)
, m_pLayoutView(NULL)
, loginNode(NULL)
, notLoginNode(NULL)
, bottomNode(NULL)
, jifenBtn(NULL)
, verNodeBtnClickTimes(0)
{

}

LeftMenuViewController::~LeftMenuViewController()
{

}

void LeftMenuViewController::onActionPerformed(LoginAction action)
{
	if (action == LoginActionLoginSuccess) {
		checkUserStatus();
	}
}

LeftMenuViewController* LeftMenuViewController::create()
{
	LeftMenuViewController* viewController = new LeftMenuViewController();
	if (viewController && viewController->init())
	{
		viewController->autorelease();
		return viewController;
	}
	CC_SAFE_DELETE(viewController);
	return NULL;
}

bool LeftMenuViewController::init()
{
	if (!CAViewController::init()) {
		return false;
	}

	//this->getView()->setColor(CAColor_black);
	m_sMyInfoString = default_user_nick;





	this->m_Cnames.push_back("CrossApp论坛");
	this->m_Cnames.push_back("geelou官网");
	this->m_Cnames.push_back("意见反馈");
	//this->m_Cnames.push_back("果冻帮助");

	//    #if CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC
	//        this->m_Cnames.push_back("A佳评分");
	//    #endif

	this->m_Cnames.push_back("设置");//this->m_Cnames.push_back("清理缓存(0.0M)");
	//this->m_Cnames.push_back("分享");
	//this->m_Cnames.push_back("抓取商品");
	//this->m_Cnames.push_back("分享商品列表");

	this->m_Cpics.push_back(GD_IMAGE_PATH + "icon_index.png");
	this->m_Cpics.push_back(GD_IMAGE_PATH + "icon_me.png");
	this->m_Cpics.push_back(GD_IMAGE_PATH + "icon_fankui.png");
	//this->m_Cpics.push_back(GD_IMAGE_PATH + "icon_help.png");

	//    #if CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC
	//        this->m_Cpics.push_back(GD_IMAGE_PATH + "icon_fankui.png");
	//    #endif

	this->m_Cpics.push_back(GD_IMAGE_PATH + "icon_clear.png");
	//this->m_Cpics.push_back(GD_IMAGE_PATH + "icon_share.png");
	//this->m_Cpics.push_back(GD_IMAGE_PATH + "icon_001.png");
	//this->m_Cpics.push_back(GD_IMAGE_PATH + "icon_001.png");

	this->m_CTags.push_back(100);
	this->m_CTags.push_back(105);
	this->m_CTags.push_back(110);
	//this->m_CTags.push_back(115);

	//    #if CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC
	//        this->m_CTags.push_back(113);
	//    #endif

	this->m_CTags.push_back(120);
	//this->m_CTags.push_back(125);
	//this->m_CTags.push_back(130);
	//this->m_CTags.push_back(131);
	return true;
}



void LeftMenuViewController::viewDidLoad()
{
	GDStatisticsUtil::onInitView("LeftMenuViewController");

	CCRect bounds = this->getView()->getBounds();

	this->getView()->setColor(CAColor_clear);

	/*
	bgImage = CAImageView::createWithFrame(CCRect(0, 0, bounds.size.width, bounds.size.height));
	bgImage->setImage(CAImage::create(GD_IMAGE_PATH+"left_bg.jpg"));
	//GDUtil::setShaderBlurImage(bgImage);
	this->getView()->addSubview(bgImage);


	CAView *bgZheZhao = CAView::createWithFrame(CCRect(0, 0, bounds.size.width, bounds.size.height));
	bgZheZhao->setColor(ccc4(0,0,0,255*0.75));
	this->getView()->addSubview(bgZheZhao);
	*/

	m_pLayoutView = CAScrollView::createWithFrame(CCRect(0, 0, bounds.size.width, bounds.size.height));
	m_pLayoutView->setBounceHorizontal(false);
	//m_pLayoutView->setTouchMovedListenHorizontal(false);
	m_pLayoutView->setShowsScrollIndicators(false);
	m_pLayoutView->setBackGroundColor(CAColor_clear);
	this->getView()->addSubview(m_pLayoutView);

	loginNode = CAView::createWithColor(CAColor_clear);
	loginNode->setFrame(CCRect(0, _ds(40), bounds.size.width, _ds(23)));
	m_pLayoutView->addSubview(loginNode);
	loginNode->setVisible(false);

	notLoginNode = CAView::createWithColor(CAColor_clear);
	notLoginNode->setFrame(CCRect(0, _ds(40), bounds.size.width, _ds(232)));

	m_pLayoutView->addSubview(notLoginNode);

	// 顶部按钮节点
	CAView *topBtnNode = CAView::createWithFrame(CCRect(0, 0, bounds.size.width, _ds(240)));
	topBtnNode->setColor(CAColor_clear);
	loginNode->addSubview(topBtnNode);

	CAButton *logoutBtn = CAButton::createWithFrame(CCRect(_ds(16), _ds(7), _ds(60), _ds(60)), CAButtonTypeCustom);
	//logoutBtn->setBackGroundViewForState(CAControlStateAll, CAView::createWithColor(CAColor_green));
	logoutBtn->addTarget(this, CAControl_selector(LeftMenuViewController::onLogoutClicke), CAControlEventTouchUpInSide);
	topBtnNode->addSubview(logoutBtn);

	CAImageView *logoutImage = CAImageView::createWithImage(CAImage::create(GD_IMAGE_PATH + "icon_logout.png"));
	logoutImage->setCenter(CCRect(logoutBtn->getBounds().size.width / 2, logoutBtn->getBounds().size.height / 2, _ds(32), _ds(34)));
	logoutBtn->addSubview(logoutImage);

	CAButton *setBtn = CAButton::createWithFrame(CCRect(bounds.size.width - _ds(50), _ds(23), _ds(32), _ds(32)), CAButtonTypeCustom);
	setBtn->setImageForState(CAControlStateAll, CAImage::create(GD_IMAGE_PATH + "icon_set.png"));
	setBtn->setVisible(false);
	topBtnNode->addSubview(setBtn);

	CAImageView* imageView2 = CAImageView::createWithImage(CAImage::create(dmDefaultHeadImage));
	imageView2->setColor(ccc4(166, 166, 166, 255));

	m_pHeadButton = CAButton::create(CAButtonTypeCustom);
	m_pHeadButton->setCenter(CCRect(bounds.size.width / 2, _ds(90), _ds(140), _ds(140)));
	topBtnNode->addSubview(m_pHeadButton);
	m_pHeadButton->addTarget(this, CAControl_selector(LeftMenuViewController::onHeadeClicke), CAControlEventTouchUpInSide);

	/*
	m_pHeadImgStatus = CAImageView::createWithImage(CAImage::create(dmDefaultHeadImage));
	m_pHeadImgStatus->setCenter(CCRect(m_pHeadButton->getBounds().size.width / 2, m_pHeadButton->getBounds().size.height / 2, _ds(124), _ds(124)));
	GDUtil::setShaderRircleImage(m_pHeadImgStatus);
	m_pHeadButton->addSubview(m_pHeadImgStatus);
	*/

	// 头像
	m_pHeadImgView = GDRoundImageView::createWithFrame(CCRect(_ds(8), _ds(8), _ds(124), _ds(124)));
	m_pHeadImgView->setBlendImage(CAImage::create(GD_IMAGE_PATH + "head_top_img.png"));
	m_pHeadButton->addSubview(m_pHeadImgView);

	addHeadForegrand();


	CAImageView *topImageView = CAImageView::createWithImage(CAImage::create(GD_IMAGE_PATH + "head_top_img.png"));
	topImageView->setCenter(CCRect(m_pHeadButton->getBounds().size.width / 2, m_pHeadButton->getBounds().size.height / 2, _ds(138), _ds(138)));
	m_pHeadButton->addSubview(topImageView);



	m_pMyInfoLabel = CALabel::createWithFrame(CCRect(0, m_pHeadButton->getFrameOrigin().y + m_pHeadButton->getBounds().size.height + _ds(16), bounds.size.width, _ds(50)));
	m_pMyInfoLabel->setTextAlignment(CATextAlignmentCenter);
	m_pMyInfoLabel->setFontSize(_px(30));
	m_pMyInfoLabel->setColor(ccc4(255, 255, 255, 255));
	m_pMyInfoLabel->setText(m_sMyInfoString);
	topBtnNode->addSubview(m_pMyInfoLabel);

	// 中部节点
	CCRect centerRect = CCRect(_ds(20), topBtnNode->getFrameOrigin().y + topBtnNode->getBounds().size.height, bounds.size.width - _ds(40), _ds(175));
	CAView *centerNode = CAView::createWithFrame(centerRect);
	centerNode->setTextTag("center_node");
	centerNode->setColor(CAColor_clear);
	loginNode->addSubview(centerNode);

	jifenBtn = GDButton::createWithFrame(CCRect(0, 0, centerRect.size.width, _ds(64)), string("积分：00"), GDButtonType_LEFT_KUANG_BTN);
	jifenBtn->addTarget(this, CAControl_selector(LeftMenuViewController::onJifenClicke), CAControlEventTouchUpInSide);
	centerNode->addSubview(jifenBtn);

	GDButton *qiandaoBtn = GDButton::createWithFrame(CCRect(0, jifenBtn->getFrameOrigin().y + jifenBtn->getBounds().size.height + _ds(16), centerRect.size.width, _ds(64)), string("签到"), GDButtonType_LEFT_BIG_BTN);
	qiandaoBtn->addTarget(this, CAControl_selector(LeftMenuViewController::onQianDaoClicke), CAControlEventTouchUpInSide);
	qiandaoBtn->setTextTag("btn_qiandao");
	centerNode->addSubview(qiandaoBtn);
	GDUtil::setViewHeight(loginNode, centerNode); // 修改高度

	CAImageView *img_status = CAImageView::createWithFrame(CCRect(qiandaoBtn->getFrame().size.width - _ds(15), 0, _ds(15), _ds(15)));
	img_status->setImage(CAImage::create("images/icon3.png"));
	img_status->setTextTag("qiandao_yuan");
	qiandaoBtn->addSubview(img_status);


	GDButton *loginbtns = GDButton::createWithFrame(CCRect(_ds(20), _ds(98), bounds.size.width - _ds(40), _ds(64)), string("注册/登录"), GDButtonType_LEFT_BIG_BTN);
	loginbtns->addTarget(this, CAControl_selector(LeftMenuViewController::onLoginClicke), CAControlEventTouchUpInSide);
	notLoginNode->addSubview(loginbtns);


	// 底部节点
	int size = (int)m_Cnames.size();
	int height = _ds(80);
	CCRect bottomRect = CCRect(0, centerNode->getFrameOrigin().y + centerNode->getBounds().size.height, bounds.size.width, size*height);
	bottomNode = CAView::createWithFrame(bottomRect);
	bottomNode->setColor(CAColor_clear);
	m_pLayoutView->addSubview(bottomNode);

	for (int i = 0; i < size; i++){
		CAView *itemNode = CAView::createWithFrame(CCRect(0, height*i, bottomRect.size.width, height));
		itemNode->setColor(CAColor_clear);
		itemNode->setTag(m_CTags.at(i));
		bottomNode->addSubview(itemNode);

		CAButton *itemBtn = CAButton::createWithFrame(CCRect(0, 0, bottomRect.size.width, height), CAButtonTypeCustom);
		itemBtn->setTag(m_CTags.at(i));
		itemBtn->addTarget(this, CAControl_selector(LeftMenuViewController::onItemClicke), CAControlEventTouchUpInSide);
		itemBtn->setBackGroundViewForState(CAControlStateAll, CAView::createWithColor(CAColor_clear));
		itemBtn->setBackGroundViewForState(CAControlStateHighlighted, CAView::createWithColor(ccc4(CAColor_black.r, CAColor_black.g, CAColor_black.b, 255 * 0.15)));
		itemNode->addSubview(itemBtn);

		CAImage *iconImage = CAImage::create(m_Cpics.at(i));
		CCSize imageSize = iconImage->getContentSize();
		CAImageView *iconImageView = CAImageView::createWithImage(iconImage);
		iconImageView->setFrame(CCRect(_ds(56), _ds(80 - imageSize.height) / 2, _ds(imageSize.width), _ds(imageSize.height)));
		itemBtn->addSubview(iconImageView);

		CALabel *itemTitle = CALabel::createWithFrame(CCRect(_ds(110), 0, itemBtn->getBounds().size.width - _ds(170), itemBtn->getBounds().size.height));
		itemTitle->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
		itemTitle->setFontSize(_ds(26));
		itemTitle->setText(m_Cnames.at(i));
		itemTitle->setColor(CAColor_white);
		itemTitle->setTag(1);
		itemBtn->addSubview(itemTitle);
	}

	verNodeBtn = CAButton::createWithFrame(CCRect(0, bottomNode->getFrameOrigin().y + bottomNode->getBounds().size.height, bottomRect.size.width, height), CAButtonTypeCustom);
	//verNodeBtn->setBackGroundViewForState(CAControlStateAll,CAView::createWithColor(CAColor_gray));
	verNodeBtn->setTag(3333);
	m_pLayoutView->addSubview(verNodeBtn);
	verNodeBtn->addTarget(this, CAControl_selector(LeftMenuViewController::onItemClicke), CAControlEventTouchUpInSide);
	std::string title = "版本号：" + APP_VER;
	CALabel *titleLable = GDUtil::createLabelWithFrame(CCRect(0, 0, verNodeBtn->getBounds().size.width, verNodeBtn->getBounds().size.height / 2), title.c_str(), CAColor_white, _ds(18), "", CATextAlignmentCenter, CAVerticalTextAlignmentCenter);
	titleLable->setTag(1);
	verNodeBtn->addSubview(titleLable);
	titleLable->setVisible(false);
	title = "地址：" + GD_DOMAIN;
	CALabel *titleLable2 = GDUtil::createLabelWithFrame(CCRect(0, titleLable->getFrameOrigin().y + titleLable->getBounds().size.height, verNodeBtn->getBounds().size.width, verNodeBtn->getBounds().size.height / 2), title.c_str(), CAColor_white, _ds(18), "", CATextAlignmentCenter, CAVerticalTextAlignmentCenter);
	titleLable2->setTag(2);
	verNodeBtn->addSubview(titleLable2);
	titleLable2->setVisible(false);
	checkUserStatus();
}

void LeftMenuViewController::imageViewRequestFinished(CommonUrlImageView* imageView){
	//m_pHeadImgStatus->setImage(imageView->getImage());
}

void LeftMenuViewController::addHeadForegrand()
{
	/*
	if (m_pHeadButton->getSubviewByTag(11)) {
	m_pHeadButton->removeSubviewByTag(11);
	}
	CAImageView *headTopView = CAImageView::create();
	headTopView->setFrame(CCRect(0, 0, _ds(180), _ds(180)));
	headTopView->setImage(CAImage::create(dmHeadTopImage));
	headTopView->setTag(11);
	m_pHeadButton->addSubview(headTopView);
	*/
}



void LeftMenuViewController::viewDidAppear()
{
	checkUserStatus();
	//UMENG_PageStart("分类");
	//if (!CAScheduler::isScheduled(schedule_selector(LeftMenuViewController::onCalculateCacheSize), this)) {
	//     CAScheduler::schedule(schedule_selector(LeftMenuViewController::onCalculateCacheSize), this, 0, 0, 1.1f, false);
	//}

	//左边找朋友新手引导

}

void LeftMenuViewController::onCalculateCacheSize(float dt){
	CAScheduler::unschedule(schedule_selector(LeftMenuViewController::onCalculateCacheSize), this);
	unsigned long m_uliTmpSize = GDUtil::getFilePathSize(___CACHE_FILE_PATH___);

	if (m_uliTmpSize / 1048576.0f >= 20){//本地缓存大于20M就给他清除掉
		onCaCheClearClicke(1);
		return;
	}
	char str[128];
	sprintf(str, "清理缓存(%.1fM)", m_uliTmpSize / 1048576.0f);
	//std::string icon_clear_str = str;
	CALabel *lblText = (CALabel*)bottomNode->getSubviewByTag(120)->getSubviewByTag(120)->getSubviewByTag(1);
	if (lblText)lblText->setText(str);
}

void LeftMenuViewController::viewDidDisappear()
{
	//UMENG_PageEnd("分类");
}

void LeftMenuViewController::onHeadeClicke(CAControl* control, CCPoint point){
	/*
	GdUserModule *gdUserModule = GdUserModule::getInstance();
	if (!gdUserModule->checkUserIsLogin()){
		gdUserModule->openUserLoginPanel(this);
		return;
	}
	else{
		gdUserModule->openModifyUserInfoPanel();
	}
	*/
}


void LeftMenuViewController::viewDidUnload()
{

}

void LeftMenuViewController::checkUserStatus()
{
	
}

void LeftMenuViewController::onLogoutClicke(CAControl* control, CCPoint point){
	
}

void LeftMenuViewController::onLoginClicke(CAControl* control, CCPoint point){
	
}

void LeftMenuViewController::logout(int index)
{
	
}

void LeftMenuViewController::onJifenClicke(CAControl* control, CCPoint point){
	
}

void LeftMenuViewController::onQianDaoClicke(CAControl* control, CCPoint point){

}

void LeftMenuViewController::onItemClicke(CAControl* control, CCPoint point){
	int index = control->getTag() - 0;

	GDStatisticsUtil::onBtnClick(CCString::createWithFormat("LeftMenuViewController::onItemClicke index:%d", index)->getCString());

	if (index == 100){
		GDUtil::pushViewController(GdWebviewViewController::create("http://www.9miao.com/forum-31-1.html", "CrossApp官方论坛"));
	}
	else if (index == 105){
		GDUtil::pushViewController(GdWebviewViewController::create("http://www.geelou.com", "geelou官网"));
	}
	else if(index == verNodeBtn->getTag()){
		verNodeBtnClickTimes++;

		if (verNodeBtnClickTimes == 4){
			verNodeBtn->getSubviewByTag(1)->setVisible(true);
		}
		if (verNodeBtnClickTimes == 9){
			IS_DEBUG = true; // 变成测试模式
			verNodeBtn->getSubviewByTag(2)->setVisible(true);
			if (IS_DEBUG) CCLog("启动debug模式");
		}
	}
}

void LeftMenuViewController::onQiandaoRequestFinished(const HttpResponseStatus& status, const CSJson::Value& json)
{
	int result = json["error_code"].asInt();

	if (IS_DEBUG) CCLog("签到结果=%s", json.toStyledString().c_str());

	if (result == 0)
	{
		//GdUserModule::getInstance()->updateGdUser(json);
		updateJiFen();
		GDUtil::alert(json["error_message"].asCString());
	}
	else
	{
		string errMsg = json["error_message"].asString();
		GDUtil::alert(errMsg.c_str());
	}
}

void LeftMenuViewController::updateJiFen(){
	
}

void LeftMenuViewController::updateCheckinsStatus(){
	
}


void LeftMenuViewController::onCaCheClearClicke(int index){
	if (index == 1){
		GDUtil::removeFilePath(___CACHE_FILE_PATH___);//删除缓存文件
		//
		CALabel *lblText = (CALabel*)bottomNode->getSubviewByTag(120)->getSubviewByTag(120)->getSubviewByTag(1);
		//lblText->setText("清理缓存(0.0M)");
		lblText->setText("清理缓存");

		CAImageCache::sharedImageCache()->removeUnusedImages();//删除缓存数据
	}
}



/*
CATableViewCell* LeftMenuViewController::tableCellAtIndex(CATableView* table, const CCSize& cellSize, unsigned int section, unsigned int row)
{

LeftMenuViewControllerCell *cell = dynamic_cast<LeftMenuViewControllerCell *>(table->dequeueReusableCellWithIdentifier("moreCell"));

if (cell == NULL)
{
CADipSize size = CADipSize(_dip(this->getView()->getFrame().size.width), 90);
cell = new LeftMenuViewControllerCell();
cell->setType(section == this->m_Cnames.size() - 1 ? 1 : 0);
cell->init("moreCell", size);
cell->setAllowsSelected(false);
cell->autorelease();
}

cell->setBotLineVisible(false);
cell->setItemImage(CAImage::create(this->m_Cpics.at(section).c_str()));
cell->setItemText(this->m_Cnames.at(section));
cell->setAccessToryVisible(true);


return cell;
}

unsigned int LeftMenuViewController::numberOfRowsInSection(CATableView *table, unsigned int section)
{
return 1;
}

unsigned int LeftMenuViewController::numberOfSections(CATableView *table)
{
return this->m_Cnames.size();
}

CAView* LeftMenuViewController::tableViewSectionViewForHeaderInSection(CATableView* table, const CCSize& viewSize, unsigned int section)
{

return NULL;
}


unsigned int LeftMenuViewController::tableViewHeightForRowAtIndexPath(CATableView* table, unsigned int section, unsigned int row)
{
return _px(90);
}



void LeftMenuViewController::tableViewDidSelectRowAtIndexPath(CATableView* table, unsigned int section, unsigned int row)
{

}

unsigned int LeftMenuViewController::tableViewHeightForHeaderInSection(CATableView* table, unsigned int section)
{
return 0;
}

*/

/////////////////////////////////         LeftMenuViewControllerCell           ////////////////////////////////////


LeftMenuViewControllerCell::LeftMenuViewControllerCell()
:m_pIemImage(NULL)
, type(0)
, arrowImage(NULL)
, m_pAccesstor(NULL)
, m_pBotLine(NULL)
, m_pItemLable(NULL)
{

}

LeftMenuViewControllerCell::~LeftMenuViewControllerCell()
{

}


bool LeftMenuViewControllerCell::init(const char* reuseIdentifier, const CADipSize& cellSize)
{


	if (this->type == 1){
		CAButton* buttonTouch = CAButton::createWithFrame(CCRect(0, 0, cellSize.width / 2, cellSize.height), CAButtonTypeCustom);
		buttonTouch->setTitleForState(CAControlStateAll, "关于果冻");
		buttonTouch->setTitleColorForState(CAControlStateNormal, ccc4(255, 255, 255, 255));
		buttonTouch->setBackGroundViewForState(CAControlStateNormal, CAView::createWithColor(ccc4(204, 0, 102, 255)));
		this->addSubview(buttonTouch);

		CAButton* buttonTouch1 = CAButton::createWithFrame(CCRect(cellSize.width / 2, 0, cellSize.width / 2, cellSize.height), CAButtonTypeCustom);
		buttonTouch1->setTitleForState(CAControlStateAll, "买手必看");
		buttonTouch1->setTitleColorForState(CAControlStateNormal, ccc4(255, 255, 255, 255));
		buttonTouch1->setBackGroundViewForState(CAControlStateNormal, CAView::createWithColor(ccc4(255, 51, 0, 255)));
		this->addSubview(buttonTouch1);
	}
	else{
		CCRect iconRect = CCRect(30, 20, 50, 50);
		this->m_pIemImage = CAImageView::createWithFrame(iconRect);
		this->addSubview(m_pIemImage);

		CCRect lableRect = CCRect(100 + (cellSize.width - 100) / 2, cellSize.height / 2, cellSize.width - 100, 50);

		this->m_pItemLable = CALabel::createWithCenter(lableRect);
		this->m_pItemLable->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
		this->m_pItemLable->setFontSize(_px(32));
		this->m_pItemLable->setColor(ccc4(255, 255, 255, 255));
		this->addSubview(m_pItemLable);

		CCRect accessRect = CCRect(cellSize.width - 60, 30, 30, 30);
		this->m_pAccesstor = CAImageView::createWithFrame(accessRect);
		this->addSubview(m_pAccesstor);

		this->arrowImage = CAImageView::createWithImage(CAImage::create("images/comm_arraw.png"));
		m_pAccesstor->addSubview(arrowImage);

		CCRect botR = CCRect(0, cellSize.height - 1, cellSize.width, 1);
		this->m_pBotLine = CAView::createWithFrame(botR);
		this->m_pBotLine->setColor(ccc4(255, 255, 255, 255));
		this->addSubview(m_pBotLine);
		this->m_pBotLine->setVisible(false);
	}
	return true;
}



void LeftMenuViewControllerCell::setItemText(std::string text)
{
	CC_RETURN_IF(this->m_pItemLable == NULL);
	this->m_pItemLable->setText(text);
}

void LeftMenuViewControllerCell::setItemImage(CAImage *image)
{
	CC_RETURN_IF(this->m_pIemImage == NULL);
	this->m_pIemImage->setImage(image);
}

void LeftMenuViewControllerCell::setAccessToryVisible(bool visible)
{
	CC_RETURN_IF(this->m_pAccesstor == NULL);
	this->m_pAccesstor->setVisible(visible);
}

void LeftMenuViewControllerCell::setBotLineVisible(bool visible)
{
	CC_RETURN_IF(this->m_pBotLine == NULL);
	this->m_pBotLine->setVisible(visible);
}

void LeftMenuViewControllerCell::normalTableViewCell()
{
	m_pBackgroundView->setColor(GDColor_LEFT_BG);
}

void LeftMenuViewControllerCell::highlightedTableViewCell()
{
	m_pBackgroundView->setColor(GDColor_LEFT_BG);
}

void LeftMenuViewControllerCell::selectedTableViewCell()
{
	m_pBackgroundView->setColor(GDColor_LEFT_BG);
}

void LeftMenuViewControllerCell::disabledTableViewCell()
{

}

void LeftMenuViewControllerCell::setType(int t)
{
	this->type = t;
}